package pattern21;

/**
 * p257
 * 中介者模式
 * @author wdl
 */
public class MediatorPattern {
    public static void main(String[] args) {
        //中介者
        ConcreteMediator mediator=new ConcreteMediator();
        //两个具体的同事类认识中介者
        ConcreteColleague1 colleague1=new ConcreteColleague1(mediator);
        ConcreteColleague2 colleague2=new ConcreteColleague2(mediator);
        //中介者认识两个具体的同事
        mediator.setColleague1(colleague1);
        mediator.setColleague2(colleague2);

        //具体同事通过中介者发送信息
        colleague1.sendMessage("吃饭了吗？");
        colleague2.sendMessage("没有，你打算请客是吗？");
    }
}
